package org.emet.jee.console.entity.sys;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.emet.jee.console.entity.BaseEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "SYS_DATA_ITEM")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DataItem extends BaseEntity {
	private DataDic parent;
	//It should be mutable
	private String key;
	//Used for display, it can be changed by website administrator
	private String value;
	private int seq;
	private Boolean editable = Boolean.TRUE;
	private Boolean enabledItem;

	@Column(name = "_key")
	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public Boolean getEnabledItem() {
		return enabledItem;
	}

	public void setEnabledItem(Boolean enabledItem) {
		this.enabledItem = enabledItem;
	}

	public Boolean getEditable() {
		return editable;
	}

	public void setEditable(Boolean editable) {
		this.editable = editable;
	}

	@Column(name = "_seq")
	public int getSeq() {
		return seq;
	}

	public void setSeq(int seq) {
		this.seq = seq;
	}

	@ManyToOne
	@JoinColumn(name = "parent_id")
	public DataDic getParent() {
		return parent;
	}

	public void setParent(DataDic parent) {
		this.parent = parent;
	}

	@Column(name = "_value")
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
